package thread;

import java.util.Scanner;

public class Demo23 {
    private static Object lock = new Object();
    public static void main(String[] args) {
        Thread t1 = new Thread(() -> {
            synchronized (lock) {
                System.out.println("t1 wait begin");
                try {
                    lock.wait();
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
                System.out.println("t1 wait end");
            }
        });

        Thread t2 = new Thread(() -> {
            System.out.println("t2 notify begin");
            Scanner sc = new Scanner(System.in);
            sc.next();
            synchronized (lock) {
                lock.notify();
            }
            System.out.println("t2 notify end");
        });

        t1.start();
        t2.start();
    }
}
